package com.csw.shoppingCartServlet.servlet;

import java.io.IOException;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.csw.shoppingCartServlet.entity.User;
import com.csw.shoppingCartServlet.service.UserService;
import com.csw.shoppingCartServlet.service.UserServiceImpl;

public class ChangeUserMessageAction extends HttpServlet {
	@Override
	public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {

		HttpSession session = request.getSession();
		String username = (String) session.getAttribute("username");
		String password = (String) session.getAttribute("password");

		String name = request.getParameter("name");

		String zipz = request.getParameter("zip");
		Integer zip = Integer.parseInt(zipz);

		String address = request.getParameter("address");

		UserService userService = new UserServiceImpl();

		User uu = new User(username, password, name, zip, address);
		userService.updateBy(uu);
		System.out.println("{{ChangeUserMessageAction uu}}=" + uu);
		response.sendRedirect(request.getContextPath() + "/ChangeUserMessageSuccess.jsp");

	}

}
